package com.bxd.baodan.activity;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.bxd.baodan.R;
import com.bxd.baodan.util.AppManager;

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("NewApi")
public class BasePreferenceActivity extends PreferenceActivity {



	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	@SuppressLint("NewApi")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		AppManager.getInstance().addActivity(this);
	}



    /**
	 * 打开指定activity
	 * 
	 * @param targetClass
	 */
	public void openActivity(Class<?> targetClass) {
		Intent intent = new Intent(this, targetClass);
		startActivity(intent);
		overridePendingTransition(R.anim.slide_in_right,
				R.anim.slide_out_left);
	}
	@Override
	public void finish() {
		super.finish();
		overridePendingTransition(0, R.anim.fade_out);
	}

	public void setActionBarTitle(String title) {
		((TextView) findViewById(R.id.bar_tv_title)).setText(title);
		((TextView) findViewById(R.id.bar_tv_title)).setVisibility(View.VISIBLE);
	}


	public void showToast(String message) {
		Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT)
				.show();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		AppManager.getInstance().finishActivity(this);
	}
}
